package com.jblog.controller.web;

import javax.servlet.http.HttpServletRequest;

import com.jblog.core.model.account.Account;
import com.jblog.core.model.site.Site;

public class SiteUtils {

    public static final String ACCOUNT_KEY = "_account_key";
    
    public static final String SITE_KEY = "_site_key";
    
    
    public static Account getAccount(HttpServletRequest request) {
        return (Account) request.getAttribute(ACCOUNT_KEY);
    }
    
    public static void setAccount(HttpServletRequest request, Account account) {
        request.setAttribute(ACCOUNT_KEY, account);
    }
    
    public static Site getSite(HttpServletRequest request) {
        return (Site) request.getAttribute(SITE_KEY);
    }
    
    public static void setSite(HttpServletRequest request, Site site) {
        request.setAttribute(SITE_KEY, site);
    }
    
    public static Long getSiteId(HttpServletRequest request) {
        return getSite(request).getId();
    }
    
}
